﻿namespace DimensionsHelper.Common.Metadata.Script;

/// <summary>
///     小数常量表达式。
/// </summary>
public class DoubleExpression : LiteralExpression
{
    /// <summary>
    ///     小数常量表达式。
    /// </summary>
    public DoubleExpression(int start) : base(LiteralKinds.Double, start)
    {
    }

    /// <summary>
    ///     当前表达式的小数值。
    /// </summary>
    public double Value { get; internal set; } = double.NaN;

    public override ExpressionBasicType Evaluate()
    {
        return new ExpressionDouble(Value);
    }

    public override void Finish(int end, string text)
    {
        base.Finish(end, text);
        Value = double.Parse(text);
    }
}